package net.ncraft.mc.easyframework.aop;

import net.ncraft.mc.easyframework.FunctionRegister;
import net.ncraft.mc.easyframework.aop.core.DefaultAspectApplication;
import net.ncraft.mc.easyframework.context.ApplicationContext;
import net.ncraft.mc.easyframework.context.anno.Autowired;
import net.ncraft.mc.easyframework.context.anno.Bean;
import net.ncraft.mc.easyframework.context.anno.Component;

@Component
public class AspectAutoRegister implements FunctionRegister {

    @Autowired
    private ApplicationContext context;

    @Autowired
    private AspectApplication aspectApplication;

    @Override
    public void register() {
        aspectApplication.scan(context);
        aspectApplication.pointcut();
    }

    @Bean(ignoreMethodName = true)
    public AspectApplication aspectApplication() {
        return new DefaultAspectApplication();
    }

}
